﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using zhangmenren.IService;
using zhangmenren.Models;
using zhangmenren.Models.ViewModle;
using zhangmenren.Repository;
using zhangmenren.ViewModel;

namespace zhangmenren.Service
{
	public class OrderService : IOrderService
	{
		private OrderRepository orderRepository = new OrderRepository();
		public Task<int> Add(OrderEntity entity)
		{
			return Task.FromResult(orderRepository.Add(entity));
		}

		public Task<IEnumerable<OrderEntity>> Select(int index, string key)
		{
			return Task.FromResult(orderRepository.Select(index,key));
		}
		public Task<OrderEntity> FindById(string orderid)
		{
			return Task.FromResult(orderRepository.FindById(orderid).FirstOrDefault());
		}
		public Task<int> Payed(string orderId)
		{
			return Task.FromResult(orderRepository.Payed(orderId));
		}

        public Task<int> Del(string orderId)
        {
            return Task.FromResult(orderRepository.Del(orderId));
        }

        public Task<IEnumerable<OrderEntity>> FindByWorkId(int workId)
        {
            return Task.FromResult(orderRepository.FindByWorkId(workId));
        }

        public Task<IEnumerable<WorksModel>> FindByUserId(int userId)
        {
            return Task.FromResult(orderRepository.FindByUserId(userId));
        }

        public Task<IEnumerable<OrderModel>> Select(int index, int lim, string key)
        {
            return Task.FromResult(orderRepository.Select(index,lim, key));
        }
    }
}
